#include<iostream>
#include<string>
using namespace std;
typedef struct node{
	char data;
	struct node *lchild;
	struct node *rchild;
}BTNode;
typedef struct node *BTree;
BTree CreateBtree(string str,int i);
int Wpl(BTree t,int len);
int main()
{
	string str;
	cin>>str;
	BTree BT=CreateBtree(str,1);
	cout<<Wpl(BT,0)<<endl;
	return 0;
 } 
int Wpl(BTree t,int len)
{
	if(t==NULL)
	 return 0;
	if(t->lchild==NULL&&t->rchild==NULL)
	 return (t->data-'0')*len;
	return Wpl(t->lchild,len+1)+Wpl(t->rchild,len+1);
}
BTree CreateBtree(string str,int i)
{
	BTree BT;
	int len;
	len = str.size();
	BT=new BTNode;
	if(i<0||i>len-1)
	 return NULL;
	if(str[i]=='#')
	 return NULL;
	BT->data=str[i];
	BT->lchild=CreateBtree(str,2*i);
	BT->rchild=CreateBtree(str,2*i+1);
	return BT;
}
